package org.iweb.html.impl.basic;

import org.iweb.html.api.AbstractHtmlElement;

public class Table extends AbstractHtmlElement {

	private static final long serialVersionUID = -1915499739227844673L;

	public Table(){
		
	}
	
	public Table(String... columns) {
		Tr tr=new Tr();
		for(String s: columns){
			tr.append(new Th(s));
		}
		append(tr);
	}
	
	public Table addRow(String... values){
		Tr tr=new Tr();
		for(String s: values){
			tr.append(new Td(s));
		}
		append(tr);
		return this;
	}
	
	public static class Tr extends AbstractHtmlElement{

		private static final long serialVersionUID = 921204079345654042L;
		
		@Override
		public String getTag() {
			return "tr";
		}
	}
	
	public static class Td extends AbstractHtmlElement{
		
		private static final long serialVersionUID = 294281416379087005L;

		public Td(String label) {
			super(label);
			removeAttr("id");			
		}
		
		@Override
		public String getTag() {
			return "td";
		}
		
	}
	
	public static class Th extends Td{

		private static final long serialVersionUID = 8988228570793637677L;

		public Th(String label) {
			super(label);
		}
		
		@Override
		public String getTag() {
			return "th";
		}
	}

}
